home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / unix / bsd / osf1 / alpha / start.S < prev    next >
Encoding:
Text File  |  1994-07-18  |  1.5 KB  |  71 lines

  1. /* Copyright (C) 1993 Free Software Foundation, Inc.
  2.    Contributed by Brendan Kehoe (brendan@zen.org).
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <sysdep.h>
  20.  
  21. #ifndef HAVE_GNU_LD
  22. #define __environ environ
  23. #endif
  24.  
  25. .comm __environ,    8
  26. .comm errno,        4
  27.  
  28. !.sdata
  29. !.globl STARTFRM
  30. !STARTFRM = 0
  31.  
  32. .text
  33. ENTRY(__start)
  34.     lda    sp, -16(sp)
  35.     stq    zero, 8(sp)
  36.  
  37.     ! This branch puts the address of the current insn in t0.
  38.     br    t0, 10f
  39. 10:
  40.     ! We set the GP register by using the address of the ldgp
  41.     ! (what we just put into t0).
  42.     ldgp    gp, 0(t0)
  43.  
  44.     ! get argc
  45.     ldl    a0, 16(sp)
  46.  
  47.     ! get argv
  48.     lda    a1, 24(sp)
  49.  
  50.     ! move ahead to envp
  51.     s8addq    a0, a1, a2
  52.     addq    a2, 0x8, a2
  53.  
  54.     ! Store in environ.
  55.     stq    a2, environ
  56.  
  57.     ! Clear out errno.
  58. !    ldgp    gp, 0(t12)
  59.     stl    zero, errno
  60.  
  61.     ! Call main.
  62.     jsr    ra, main
  63.     ldgp    gp, 0(ra)
  64.  
  65.     mov    v0, a0
  66.  
  67.     jsr    ra, exit
  68.     ldgp    gp, 0(ra)
  69.  
  70.     .end __start
  71.